﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.IO;

namespace Robotics.Race
{
    [Serializable]
    public class GlobalSettings
    {
        private static GlobalSettings instance = new GlobalSettings();
        public static GlobalSettings Instance { get { return instance; } set { instance = value; } }
        private static string settingsFilename = "GlobalSettngs.cfg";

        public static void Save()
        {
            SerializationUtil<GlobalSettings> su = new SerializationUtil<GlobalSettings>();
            if (File.Exists(settingsFilename))
                File.Delete(settingsFilename);
            su.Save(Instance, settingsFilename);
        }

        public static void Load()
        {
            SerializationUtil<GlobalSettings> su = new SerializationUtil<GlobalSettings>();
            if (!File.Exists(settingsFilename))
                Instance = new GlobalSettings();
            else
                Instance = su.Load(settingsFilename);
        }

        int standingTurnSpeed = 25;
        public int StandingTurnSpeed { get { return standingTurnSpeed; } set { standingTurnSpeed = value; } }

        double turnFactor = 0.6;
        public double TurnFactor { get { return turnFactor; } set { turnFactor = value; } }

        double accelerationFactor = 8.0;
        public double AccelerationRatio { get { return accelerationFactor; } set { accelerationFactor = value; } }

        double frictionRatio = 2.0;
        [ReadOnly(false)] 
        public double FrictionRatio { get { return frictionRatio; } set { frictionRatio = value; } }

        //int updateIntervalMs = 50;
        //public int UpdateIntervalMs { get { return updateIntervalMs; } set { updateIntervalMs = value; } }

        //int senseIntervalMs = 50;
        //public int SenseIntervalMs { get { return senseIntervalMs; } set { senseIntervalMs = value; } }

        
    }
}
